<?php
$cid        = gpc_getStringArray('cid');
$name       = "";

if(count($cid)==0)
{
    $cid[0]=$id;
}

foreach($cid as $id)
{
    $sql_select = "SELECT cName,iParentId FROM tbllocation WHERE iId = '$id'";
    $rs=$dbsql->query($sql_select);
    if($result = $dbsql->fetch_array($rs))
    {
    	$name          .= $result["cName"].", ";
        $idparent       = $result['iParentId'];
    }
    $pagetr = empty($pagetr) ? "id=$idparent" : $pagetr;

    if(hasChildLocation($id))
    {
    	$msg = "Can't Delete Location: $name - has Child!";
     	error_transfer($msg,$pagetr);
    	exit();

    }
    $sql_delete = "DELETE FROM tbllocation WHERE iId ='$id'";
    $dbsql->query($sql_delete);
}

Insert_Tracking(" Del Location $name");
page_transfer("Delete Location Success",$pagetr);
exit();
?>